/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年2月16日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

import java.util.HashMap;

/**
 * @Type A20200216_fbnq
 * @Desc
 * @author 52489
 * @date 2020年2月16日
 * @Version V1.0
 */
public class A20200216_fbnq {
    static HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

    public static void main(String[] args) {
        System.out.println(fab(6));
    }

    /**
     * @param i
     * @return
     */
    private static int fab(int i) {
        if (i == 1 || i == 2) {
            return 1;
        }
        if (map.containsKey(i)) {
            return map.get(i);
        } else {
            int value = fab(i - 1) + fab(i - 2);
            map.put(i, value);
            return value;
        }
    }

    /**
     * @param map2
     * @param i
     * @return
     */
    private static int helper(HashMap<Integer, Integer> map2, int i) {
        map.put(i, helper(map, i - 1) + helper(map, i - 2));
        return map.get(i);
    }

}
